{template header}
<link rel="stylesheet" href="/static/calendar/js/calendar.css" />
<script type="text/javascript" charset="utf-8" src="/static/calendar/calendar.php"></script>
<style type="text/css">
    .boardDiv, .tagDiv{margin-bottom: 10px;}
    .boardDiv, .tagDiv{clear: both;}
    .boardList, .tagList{margin: 10px auto;}

    .tagList li{background-color: #CED7E0;}
    .boardList label, 
    .tagList label{float: left;margin-bottom: 0;}
    .boardList label input, 
    .tagList label input {float: left;margin-right: 5px;}
    a.btn-primary {margin-top: 3px;}
    #subButton {display: none;}
    code {padding:5px 10px;}
    .noa {font-weight:bold; color:#333}
    td{font-size: 12px;}
    .t-width td {
         max-width: 240px;
        text-align: left;
    }
   
 
</style>
<script type="text/javascript">
    $(document).ready(function(){
        var bid = "{$boardId}";
        var tid = "{$tagId}";
        bid = bid.toString();
        if(tid > 0) {
            for(var i=0,e=$("#tagList>li");i<e.length;i++){
                if(e[i].getAttribute("data-value") == tid.toString()) {
                    e[i].style.backgroundColor="yellow";
                }
            }
        }
        for(var i=0,e=$("#boardList>li");i<e.length;i++){
            if(e[i].getAttribute("data-value") == bid) {
                e[i].style.backgroundColor="yellow";
            }
        }
        $("input#selectAll").click(function(){
            var isChecked = $(this).prop("checked");
            for (var i=0,e=$("td :checkbox"); i<e.length; i++){
                $(e[i]).prop("checked",isChecked);
            }
            return;
        });
        $("span#subButton").click(function(e){
          $(this).prop("checked",false);
          var action = $("select[name='action']").val();

          var postId = '';
          var e = $("td :checkbox");
          for (var i=0,len=e.length; i<len; i++) {
            if(e[i].checked == true) {
                postId += e[i].value+',';
            }
          }
          if(postId == '') {
            alert('请选择最少一个帖子');
            $(this).prop("checked",true);
            return;
          }
          if(action == '') {
            alert('请选择操作类型');
            $(this).prop("checked",true);
            return;
          }
          $.ajax({url:"index.php?c=admin&a=batchPost&postId="+postId+"&action="+action,
                  async: true,
                  type: 'GET',
                  dataType:"json",
                  error:function(){
                      alert('未知错误');
                      },
                  success:function(data, status){
                    turnData = eval(data);
                    if(turnData.message == ''){
                        var msg = ''
                        for(var i=0; i<turnData.rel.length; i++){
                          val = turnData.rel[i];
                          msg += turnData.rel[i].pid+': '+ turnData.rel[i].suc + "\n";
                        }
                        alert(msg);
                    }
                    else
                    {
                      alert(turnData.message);
                    }
                    $("input#newTag").toggleClass("hide");
                    $("span#subNewTag").toggleClass("hide");
                  }
              });
           $(this).prop("checked",true);
          return true;
      });
    });
    function showSubButton(type)
    {
        if(type != '') {
            $("span#subButton").show();
        }
        else {
            $("span#subButton").hide();
        }
    }
</script>
<h4 style="padding-left:10px;">
        <span>搜索</span>
        <i class="icon-search"></i>
        <span>关键词头尾加上英文双引号表示精确匹配</span>
</h4>
<form class="form-horizontal" method="post" action="index.php?c=admin&a=postList">
    <div class="control-group search-group" style="margin:0;" >
        <label class="control-label" style="text-align:left; text-indent:12px; " >ID或关键词</label>
        <div class="controls">
          <input type="text" placeholder="设置后忽略其他项" name="title" value="{$search['title']}">
        </div>
    </div>
    
    <div class="control-group search-group" style="margin:0;" >
        <label class="control-label" style="text-align:left; text-indent:12px; " >开始时间</label>
        <div class="controls">
            <input type="text" name="starttime" id="start_time_id" value="{$search['starttime']}" style="width: 140px;">
            <input type="button" id="start_time_btn" onclick="return showCalendar('start_time_id', '%Y-%m-%d %H:%M:%S', '24', false, 'start_time_btn');" value="选择" style="width:50px"/>  
        </div>
    </div>
    
    <div class="control-group search-group" style="margin:0;" >
        <label class="control-label" style="text-align:left; text-indent:12px; " >结束时间</label>
        <div class="controls">
            <input type="text" name="endtime" id="end_time_id" value="{$search['endtime']}" style="width: 140px;">
            <input type="button" id="end_time_btn" onclick="return showCalendar('end_time_id', '%Y-%m-%d %H:%M:%S', '24', false, 'start_time_btn');" value="选择" style="width:50px"/>  
        </div>
    </div>
    
    <div class="control-group search-group" style="margin:0;" >
        <div class="controls">
            <input type="hidden" value="1" name="isSearch">
            <button class="btn mr10" type="submit">提交</button>　
            <button class="btn" type="reset">重置</button>
        </div>
    </div>
</form>
<div class="boardDiv pt-10">
  <ul id="boardList" class="boardList">
    {loop $boardList $k $v}
      <li data-value="{$v['boardId']}"><a href="index.php?c=admin&a=postList&boardId={$v['boardId']}&uid={$uid}&gid={$gid}">{$v['boardName']}</a></li>
    {/loop}
  </ul>
</div>
<div class="tagDiv">
  <ul id="tagList" class="tagList cl">
    {loop $tagList $k $v}
      <li data-value="{$v['tagId']}"><a href="index.php?c=admin&a=postList&boardId={$boardId}&tagId={$v['tagId']}&uid={$uid}">{$v['tagName']}</a></li>
    {/loop}

  </ul>
</div>
<hr style="clear:both;" />
<div class="sxDiv" style="clear:both;">
    <span class=""><b>筛选：</b></span>
    <span>
    {loop $sxs $sk $sv}
    {if $sx == $sk}<code class="noa">{$sv}</code>{else}<code><a href="index.php?c=admin&a=postList&boardId={$boardId}&tagId={$tagId}&uid={$uid}&sx={$sk}">{$sv}</a></code>{/if}
    {/loop}
    </span>
</div>
<hr style="clear:both;" />
<div class="bs-docs-example" style="clear:both;">
    <table class="table table-striped t-width">
        <thead>
            <tr>
                <th width="15"><label for="selectAll"><input type="checkbox" id="selectAll">帖子ID</label></th>
                <th>发帖</th>
                <th>标题</th>
                <th>内容</th>
                <th>版块</th>
                <th>标签</th>
                <th width="145">添加时间|最后更新<br>最后评论</th>
                <th>总评论</th>
                <th>喜欢</th>
                <th>显示</th>
                <th>首页热门</th>
                <th>精华</th>
                <th>置顶</th>
                <th>来源</th>
                <th width="150">操作</th>
            </tr>
        </thead>
        <tbody>
            {loop $postList $k $v}
            <tr id={$v['news_id']}>
                <td width="50">
                    <input type="checkbox" name="news_id[]" value="{$v['news_id']}" id="news_{$v['news_id']}">
                    {$v['news_id']}
                </td>
                <td>
                    <a href="?c=admin&a=userinfo&uid={$v['uid']}"><img width="50" src="{$v['header']}"><br>{$v['nickname']}</a>
                </td>
                <td>{$v['title']}</td>
                <td>{$v['content']}</td>
                <td>{loop $v['board'] $kk $board}<div id="{$board['boardId']">{$board['boardName']}</div>{/loop}</td>
                <td>{loop $v['tag'] $kk $tag}<div id="{$tag['tagId']}">{$tag['tagName']}</div>{/loop}</td>
                <td>
                    {$v['real_addtime']}<br>
                    {$v['lastupdate']}<br>
                    {if $v['lastComment']}{$v['lastComment']}{else}无评论{/if}
                </td>
                <td>{$v['total_comment']}</td>
                <td>{$v['loves']}</td>
                <td>{if $v['is_show'] == 0}<i class="icon-remove">{else}<i class="icon-ok">{/if}</i></td>
                <td>{if $v['isHomeBest'] == 0}<i class="icon-remove">{else}<i class="icon-ok">{/if}</i></td>
                <td>{if $v['isBest'] == 0}<i class="icon-remove">{else}<i class="icon-ok">{/if}</i></td>
                <td>{if $v['is_top'] == 0}<i class="icon-remove">{else}<i class="icon-ok">{/if}</i></td>
                <td>{if $v['source_client']==1}PC{else}APP{/if}</td>
                <td>
                    <a class="btn btn-primary" href="?c=admin&a=postInfo&action=edit&postId={$v['news_id']}">编辑</a>&nbsp;
                    <a class="btn btn-primary" href="?c=admin&a=commentList&news_id={$v['news_id']}">查看评论</a>&nbsp;
                    <a class="btn btn-primary" href="?c=admin&a=addNewsComment&news_id={$v['news_id']}&p={$p}&boardId={$boardId}">加评</a>&nbsp;
                </td>
            </tr>
            {/loop}
            <tr class="setTr">
                <td>
                    <select style="width:150px;" name="action" onchange="showSubButton(this.value)">
                        <option value="">想干什么……</option>
                        <!-- <option value="HomeHot">首页热门</option> -->
                        <!-- <option value="cancelHomeHot">取消首页热门</option> -->
                        <option value="Best">精华</option>
                        <option value="cancelBest">取消精华</option>
                        <option value="Top">置顶</option>
                        <option value="cancelTop">取消置顶</option>
                        <option value="Recommend">推荐</option>
                        <option value="cancelRecommend">取消推荐</option>
                    </select>
                </td>
                <td colspan="9"><span id="subButton"><input type="submit" class="btn" value="确定"></span></td>
            </tr>
        </tbody>
    </table>
</div>
<!-- </form> -->
<div class="pagination">
    <ul>
        {$pageStr}
    </ul>
</div>
{template footer}
